package com.baizhi.service.impl;

import com.baizhi.dao.ExamDao;
import com.baizhi.entity.Exam;
import com.baizhi.service.ExamService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExamServiceImpl implements ExamService {
    private ExamDao examDao;
    @Autowired
    public void setExamDao(ExamDao examDao) {
        this.examDao = examDao;
    }

    @Override
    public void insertExam(Exam exam) {
        examDao.insertExam(exam);
    }

    @Override
    public Exam selectById(Integer eid) {
        Exam exam = examDao.selectById(eid);
        return exam;
    }

    @Override
    public void updateExam(Exam exam) {
        examDao.updateExam(exam);
    }

    @Override
    public PageInfo<Exam> selectExams(String name, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Exam> exams = examDao.selectExams(name);
        PageInfo<Exam> pageInfo = new PageInfo<>(exams);
        return pageInfo;
    }
}
